package com.businesscard.system.mapper;

import com.businesscard.system.entity.BusinessCard;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Map;

@Mapper
public interface BusinessCardMapper {
    
    // 插入新名片
    int insertCard(BusinessCard card);
    
    // 批量插入名片
    int batchInsertCards(List<BusinessCard> cards);
    
    // 更新名片信息
    int updateCard(BusinessCard card);
    
    // 根据ID查询名片
    BusinessCard selectCardById(@Param("id") Integer id);
    
    // 根据名片夹ID查询所有未删除的名片
    List<BusinessCard> selectCardsByFolderId(@Param("folderId") Integer folderId);
    
    // 查询名片夹中已删除的名片(回收站)
    List<BusinessCard> selectDeletedCardsByFolderId(@Param("folderId") Integer folderId);
    
    // 逻辑删除名片(移入回收站)
    int logicalDeleteCard(@Param("id") Integer id);
    
    // 逻辑删除名片夹下所有名片
    int logicalDeleteCardsByFolderId(@Param("folderId") Integer folderId);
    
    // 恢复已删除的名片
    int restoreCard(@Param("id") Integer id);
    
    // 恢复名片夹下所有名片
    int restoreCardsByFolderId(@Param("folderId") Integer folderId);
    
    // 彻底删除名片
    int deleteCard(@Param("id") Integer id);
    
    // 彻底删除名片夹下所有名片
    int deleteCardsByFolderId(@Param("folderId") Integer folderId);
    
    // 根据名片夹ID查询名片数量 (未删除的)
    Integer countCardsByFolderId(@Param("folderId") Integer folderId);
    
    // 条件查询名片
    List<BusinessCard> searchCards(Map<String, Object> params);
    
    // 批量更新名片特定字段
    int batchUpdateCards(@Param("cardIds") List<Integer> cardIds, @Param("fieldName") String fieldName, @Param("newValue") String newValue);
} 